<!-- TOP NAVIGATION MENU FROM DATABASE-->
<TABLE border="0" cellpadding="0" cellspacing="0" width="100%" class="topNavTable" align="center">
<TR>	
<?php
global $xoopsDB,$xoopsUser;
$result = $xoopsDB->query("SELECT * FROM ".$xoopsDB->prefix("tmenu")." WHERE hide=0 ORDER BY weight ASC");

$mod = $GLOBALS['xoopsModule'];
$dirname = (isset($mod) ? $mod->getVar('dirname') :'system');

	$x=0;
	while ( $myrow = $xoopsDB->fetchArray($result) ) {
		$data[$x][title] = $myrow['title'];
		$data[$x][target] = $myrow['target'];
		$data[$x][links] = $myrow['link'];
		$data[$x][module] = $myrow['module'];
		++$x;
    }//end while
	 
	 
	
	$percent = round((100/count($data))) . "%";
	//$_SESSION['ID'] = $_GET['ID']

for ($i = 0; $i < count($data); $i++) {
	if($data[$i]['module'] == $dirname){ 
		if($i == (count($data)-1)){
			echo "<TD class=\"topNavCellActive\" width=\"$percent\">::" . $data[$i]['title']. "</TD>";
		}else{
			echo "<TD class=\"topNavCellActive\" width=\"$percent\">::" . $data[$i]['title']. "</TD><td class='divider' valign='middle' align='center'>&nbsp;</td>"; 
		}
	}else{
		if($i == (count($data)-1)){
			echo "<TD class=\"topNavCell\" width=\"$percent\"><A href=\"".$data[$i]['links']."\" TARGET=\"".$data[$i]['target']."\">" . $data[$i]['title'] . "</a></TD>"; 
		}else{
			echo "<TD class=\"topNavCell\" width=\"$percent\"><A href=\"".$data[$i]['links']."\" TARGET=\"".$data[$i]['target']."\">" . $data[$i]['title'] . "</a></TD><td class='divider' valign='middle' align='center'>&nbsp;</td>"; 
		} 
	} 

}	 
?> 
</TR></TABLE>
